<template>
  <Layout title="房屋信息" :has-back="true" :has-tabbar="false" ref="layout">
    <view
      style="
        padding: 20rpx;
        height: 100%;
        width: 100%;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
      "
    >
      <view
        style="flex: 1; min-height: 0; margin-top: 20rpx; margin-bottom: 20rpx"
      >
        <Scroll>
          <u-form
            :model="formData"
            ref="form"
            :label-style="{ fontSize: '40rpx' }"
          >
            <u-form-item label="组团">
              <u-input
                v-model="formData.groupName"
                @tap="showGroupPicker"
                :readonly="true"
              ></u-input>
              <u-picker
                :show="groupName.show"
                @cancel="closeGroupPicker"
                @confirm="groupPickerConfirm"
                :columns="groupName.columns"
                keyName="label"
                :immediateChange="true"
              ></u-picker>
            </u-form-item>
            <u-form-item label="姓名" prop="name">
              <view class="input">
                <u-input
                  v-model="formData.name"
                  :clearable="true"
                  @tap.self="showNamePicker"
                  @change="nameInput"
                  @clear="nameClear"
                  :readonly="!name.show"
                  :disabled="baseOwner.length === 0"
                ></u-input>
              </view>
              <u-picker
                ref="namePicker"
                :show="name.show"
                @cancel="closeNamePicker"
                @confirm="namePickerConfirm"
                :columns="name.columns"
                keyName="label"
                :immediateChange="true"
              ></u-picker>
            </u-form-item>
            <u-form-item label="路址" prop="address">
              <view class="input">
                <u-input
                  v-model="formData.address"
                  :clearable="true"
                  @tap.self="showAddressPicker"
                  @change="addressInput"
                  @clear="addressClear"
                  :readonly="!address.show"
                  :disabled="baseOwner.length === 0"
                ></u-input>
              </view>
              <u-picker
                ref="addressPicker"
                :show="address.show"
                @cancel="closeAddressPicker"
                @confirm="addressPickerConfirm"
                :columns="address.columns"
                keyName="label"
                :immediateChange="true"
              ></u-picker>
            </u-form-item>
            <u-form-item label="类型">
              <u-input
                v-model="formData.homeType"
                @tap="showHomeTypePicker"
                :readonly="true"
              ></u-input>
              <u-picker
                :show="homeType.show"
                @cancel="closeHomeTypePicker"
                @confirm="homeTypePickerConfirm"
                :columns="homeType.columns"
                keyName="label"
                :immediateChange="true"
              ></u-picker>
            </u-form-item>
            <u-form-item label="状态">
              <u-input
                v-model="formData.homeStatus"
                @tap="showHomeStatusPicker"
                :readonly="true"
              ></u-input>
              <u-picker
                :show="homeStatus.show"
                @cancel="closeHomeStatusPicker"
                @confirm="homeStatusPickerConfirm"
                :columns="homeStatus.columns"
                keyName="label"
                :immediateChange="true"
              ></u-picker>
            </u-form-item>
            <u-form-item label="装修">
              <u-input
                v-model="decorationStatus.value"
                @tap="showDecorationStatusPicker"
                :readonly="true"
              ></u-input>
              <u-picker
                :show="decorationStatus.show"
                @cancel="closeDecorationStatusPicker"
                @confirm="decorationStatusPickerConfirm"
                :columns="decorationStatus.columns"
                keyName="label"
                :immediateChange="true"
              ></u-picker>
            </u-form-item>
            <u-form-item label="常住">
              <u-input
                v-model="liveStatus.value"
                @tap="showLiveStatusPicker"
                :readonly="true"
              ></u-input>
              <u-picker
                :show="liveStatus.show"
                @cancel="closeLiveStatusPicker"
                @confirm="liveStatusPickerConfirm"
                :columns="liveStatus.columns"
                keyName="label"
                :immediateChange="true"
              ></u-picker>
            </u-form-item>
            <u-form-item label="友好">
              <u-input
                v-model="ownerType.value"
                @tap="showOwnerTypePicker"
                :readonly="true"
              ></u-input>
              <u-picker
                :show="ownerType.show"
                @cancel="closeOwnerTypePicker"
                @confirm="ownerTypePickerConfirm"
                :columns="ownerType.columns"
                keyName="label"
                :immediateChange="true"
              ></u-picker>
            </u-form-item>
          </u-form>
        </Scroll>
      </view>
      <u-button @click="search" type="primary">
        <text style="font-size: 40rpx">筛选</text>
      </u-button>
    </view>
  </Layout>
</template>

<script>
import Layout from "@/pages/component/layout/index.vue";
import Scroll from "@/pages/component/scroll/index.vue";
import { getPickerValue } from "@/util/picker";
import { getOwnerByAll } from "@/api/owner";

export default {
  name: "HomeInfo",
  components: {
    Layout,
    Scroll,
  },
  onLoad() {
    getOwnerByAll()
      .then((result) => {
        this.allOwner = result.data.list.map((owner) => {
          return {
            ...owner,
            departmentQuestion: JSON.parse(owner.departmentQuestion),
            payMonth: JSON.parse(owner.payMonth),
          };
        });
        this.baseOwner = this.allOwner;
      })
      .catch((error) => {});
    this.$refs.form.setRules({
      name: [
        {
          trigger: ["change", "blur"],
          validator: (rule, value, callback) => {
            if (value.length === 0) {
              return callback();
            }
            let index = this.allOwner
              .filter((owner) => {
                if (!this.formData.groupName) {
                  return true;
                } else {
                  return owner.groupName === this.formData.groupName;
                }
              })
              .findIndex((item) => {
                return item.name === value;
              });
            if (index === -1) {
              return callback(new Error("业主姓名不存在"));
            } else {
              return callback();
            }
          },
        },
      ],
      address: [
        {
          trigger: ["change", "blur"],
          validator: (rule, value, callback) => {
            if (value.length === 0) {
              return callback();
            }
            let index = this.allOwner
              .filter((owner) => {
                if (!this.formData.groupName) {
                  return true;
                } else {
                  return owner.groupName === this.formData.groupName;
                }
              })
              .findIndex((item) => {
                return item.address === value;
              });
            if (index === -1) {
              return callback(new Error("房屋地址不存在"));
            } else {
              return callback();
            }
          },
        },
      ],
    });
  },
  data() {
    return {
      baseOwner: [],
      formData: {
        uuid: "",
        groupName: "",
        address: "",
        name: "",
        homeType: "",
        homeStatus: "",
        decorationStatus: "",
        liveStatus: "",
        ownerType: "",
        payStyle: "",
        payMonth: [],
      },
      allOwner: [],
      name: {
        show: false,
        columns: [[]],
      },
      address: {
        show: false,
        columns: [[]],
      },
      ownerType: {
        value: "",
        show: false,
        columns: [
          [
            {
              label: "忽略",
              value: "",
            },
            {
              label: "A 友好关系户",
              value: "A 友好关系户",
            },
            {
              label: "B 一般客户",
              value: "B 一般客户",
            },
            {
              label: "E 意见客户",
              value: "E 意见客户",
            },
          ],
        ],
      },
      liveStatus: {
        value: "",
        show: false,
        columns: [
          [
            {
              label: "忽略",
              value: "",
            },
            {
              label: "是",
              value: "1",
            },
            {
              label: "否",
              value: "2",
            },
          ],
        ],
      },
      groupName: {
        show: false,
        columns: [
          [
            {
              label: "忽略",
              value: "",
            },
            {
              label: "超豪样板间",
              value: "超豪样板间",
            },
            {
              label: "峰景",
              value: "峰景",
            },
            {
              label: "凤鸣翠岭",
              value: "凤鸣翠岭",
            },
            {
              label: "观山",
              value: "观山",
            },
            {
              label: "观山二期",
              value: "观山二期",
            },
            {
              label: "山居小墅",
              value: "山居小墅",
            },
            {
              label: "山语",
              value: "山语",
            },
            {
              label: "商铺",
              value: "商铺",
            },
            {
              label: "桐林人家",
              value: "桐林人家",
            },
            {
              label: "玺园",
              value: "玺园",
            },
            {
              label: "映山",
              value: "映山",
            },
            {
              label: "锦绣江山",
              value: "锦绣江山",
            },
          ],
        ],
      },
      homeType: {
        show: false,
        columns: [
          [
            {
              label: "忽略",
              value: "",
            },
            {
              label: "住宅",
              value: "住宅",
            },
            {
              label: "商铺",
              value: "商铺",
            },
            {
              label: "车库",
              value: "车库",
            },
            {
              label: "车位",
              value: "车位",
            },
          ],
        ],
      },
      homeStatus: {
        show: false,
        columns: [
          [
            {
              label: "忽略",
              value: "",
            },
            {
              label: "已售已收楼",
              value: "已售已收楼",
            },
            {
              label: "应收未收楼",
              value: "应收未收楼",
            },
            {
              label: "已售未到合同收楼期",
              value: "已售未到合同收楼期",
            },
            {
              label: "未收空置",
              value: "未收空置",
            },
          ],
        ],
      },
      decorationStatus: {
        value: "",
        show: false,
        columns: [
          [
            {
              label: "忽略",
              value: "",
            },
            {
              label: "是",
              value: "1",
            },
            {
              label: "否",
              value: "2",
            },
          ],
        ],
      },
    };
  },
  methods: {
    namePickerConfirm(event) {
      let item = getPickerValue(event)[0].value;
      if (event.value) {
        let owner = this.baseOwner.filter((owner) => {
          return owner.name === item.name;
        });
        if (owner.length === 1) {
          owner = owner[0];
          this.formData = {
            uuid: owner.uuid,
            groupName: owner.groupName,
            address: owner.address,
            name: owner.name,
            homeType: owner.homeType,
            homeStatus: owner.homeStatus,
            decorationStatus: owner.decorationStatus,
            liveStatus: owner.liveStatus,
            ownerType: owner.ownerType,
            payStyle: "",
            payMonth: [],
          };
          if (owner.decorationStatus === "1") {
            this.decorationStatus.value = "是";
          } else if (owner.decorationStatus === "2") {
            this.decorationStatus.value = "否";
          }
          if (owner.liveStatus === "1") {
            this.liveStatus.value = "是";
          } else if (owner.liveStatus === "2") {
            this.liveStatus.value = "否";
          }
          this.ownerType.value = owner.ownerType;
        } else {
          this.formData.name = item.name;
          this.formData.address = "";
        }
      }
      this.closeNamePicker();
      this.$refs.form.validate();
    },
    addressPickerConfirm(event) {
      let item = getPickerValue(event)[0].value;
      let owner = this.baseOwner.filter((owner) => {
        return owner.address === item.address;
      });
      if (owner.length === 1) {
        owner = owner[0];
        this.formData = {
          uuid: owner.uuid,
          groupName: owner.groupName,
          address: owner.address,
          name: owner.name,
          homeType: owner.homeType,
          homeStatus: owner.homeStatus,
          decorationStatus: owner.decorationStatus,
          liveStatus: owner.liveStatus,
          ownerType: owner.ownerType,
          payStyle: "",
          payMonth: [],
        };
        if (owner.decorationStatus === "1") {
          this.decorationStatus.value = "是";
        } else if (owner.decorationStatus === "2") {
          this.decorationStatus.value = "否";
        }
        if (owner.liveStatus === "1") {
          this.liveStatus.value = "是";
        } else if (owner.liveStatus === "2") {
          this.liveStatus.value = "否";
        }
        this.ownerType.value = owner.ownerType;
      } else {
        this.formData.address = "";
      }
      this.closeAddressPicker();
      this.$refs.form.validate();
    },
    nameClear() {
      this.formData.name = "";
      this.nameInput(this.formData.name);
    },
    addressClear() {
      this.formData.address = "";
      this.addressInput(this.formData.address);
    },
    nameInput(event) {
      uni.showLoading({ title: "请稍候", mask: true });
      this.formData.uuid = "";
      let ownerList = this.baseOwner.filter((owner) => {
        return owner.name === event;
      });
      if (ownerList.length === 1) {
        let owner = ownerList[0];
        this.formData = {
          uuid: owner.uuid,
          groupName: owner.groupName,
          address: owner.address,
          name: owner.name,
          homeType: owner.homeType,
          homeStatus: owner.homeStatus,
          decorationStatus: owner.decorationStatus,
          liveStatus: owner.liveStatus,
          ownerType: owner.ownerType,
          payStyle: "",
          payMonth: [],
        };
        if (owner.decorationStatus === "1") {
          this.decorationStatus.value = "是";
        } else if (owner.decorationStatus === "2") {
          this.decorationStatus.value = "否";
        }
        if (owner.liveStatus === "1") {
          this.liveStatus.value = "是";
        } else if (owner.liveStatus === "2") {
          this.liveStatus.value = "否";
        }
        this.ownerType.value = owner.ownerType;
      } else {
        this.formData = {
          uuid: "",
          groupName: this.formData.groupName,
          address: "",
          name: event,
          homeType: "",
          homeStatus: "",
          decorationStatus: "",
          liveStatus: "",
          ownerType: "",
          payStyle: "",
          payMonth: [],
        };
        this.decorationStatus.value = "";
        this.liveStatus.value = "";
        this.ownerType.value = "";
      }
      let index = 0;
      let allNameColumn = [];
      if (!this.formData.address) {
        if (!this.formData.name) {
          allNameColumn = this.baseOwner
            .sort((a, b) => {
              return a.name.localeCompare(b.name);
            })
            .map((owner) => {
              return {
                label: `(${++index}) ${owner.name}`,
                value: { address: owner.address, name: owner.name },
              };
            });
        } else {
          allNameColumn = this.baseOwner
            .filter((owner) => {
              return owner.name.includes(this.formData.name);
            })
            .sort((a, b) => {
              return a.name.localeCompare(b.name);
            })
            .map((owner) => {
              return {
                label: `(${++index}) ${owner.name}`,
                value: { address: owner.address, name: owner.name },
              };
            });
        }
      } else {
        let hasIndex = this.baseOwner.findIndex((owner) => {
          return owner.address === this.formData.address;
        });
        if (hasIndex === -1) {
          allNameColumn = [];
        } else {
          if (!this.formData.name) {
            allNameColumn = this.baseOwner
              .filter((owner) => {
                return owner.address === this.formData.address;
              })
              .sort((a, b) => {
                return a.name.localeCompare(b.name);
              })
              .map((owner) => {
                return {
                  label: `(${++index}) ${owner.name}`,
                  value: { address: owner.address, name: owner.name },
                };
              });
          } else {
            allNameColumn = this.baseOwner
              .filter((owner) => {
                return (
                  owner.address === this.formData.address &&
                  owner.name.includes(this.formData.name)
                );
              })
              .sort((a, b) => {
                return a.name.localeCompare(b.name);
              })
              .map((owner) => {
                return {
                  label: `(${++index}) ${owner.name}`,
                  value: { address: owner.address, name: owner.name },
                };
              });
          }
        }
      }
      this.name.columns = [allNameColumn];
      uni.hideLoading();
      index = this.name.columns[0].findIndex((item) => {
        return item.value.name.includes(this.formData.name);
      });
      if (index !== -1) {
        this.$refs.namePicker.setIndexs([index]);
      }
    },
    addressInput(event) {
      uni.showLoading({ title: "请稍候", mask: true });
      this.formData.uuid = "";
      let ownerList = this.baseOwner.filter((owner) => {
        return owner.address === event;
      });
      if (ownerList.length === 1) {
        let owner = ownerList[0];
        this.formData = {
          uuid: owner.uuid,
          groupName: owner.groupName,
          address: owner.address,
          name: owner.name,
          homeType: owner.homeType,
          homeStatus: owner.homeStatus,
          decorationStatus: owner.decorationStatus,
          liveStatus: owner.liveStatus,
          ownerType: owner.ownerType,
          payStyle: "",
          payMonth: [],
        };
        if (owner.decorationStatus === "1") {
          this.decorationStatus.value = "是";
        } else if (owner.decorationStatus === "2") {
          this.decorationStatus.value = "否";
        }
        if (owner.liveStatus === "1") {
          this.liveStatus.value = "是";
        } else if (owner.liveStatus === "2") {
          this.liveStatus.value = "否";
        }
        this.ownerType.value = owner.ownerType;
      } else {
        this.formData = {
          uuid: "",
          groupName: this.formData.groupName,
          address: event,
          name: "",
          homeType: "",
          homeStatus: "",
          decorationStatus: "",
          liveStatus: "",
          ownerType: "",
          payStyle: "",
          payMonth: [],
        };
        this.decorationStatus.value = "";
        this.liveStatus.value = "";
        this.ownerType.value = "";
      }
      let index = 0;
      let allAddressColumn = [];
      if (!this.formData.name) {
        if (!this.formData.address) {
          allAddressColumn = this.baseOwner
            .sort((a, b) => {
              return a.address.localeCompare(b.address);
            })
            .map((owner) => {
              return {
                label: `(${++index}) ${owner.address}`,
                value: { address: owner.address, name: owner.name },
              };
            });
        } else {
          allAddressColumn = this.baseOwner
            .filter((owner) => {
              return owner.address.includes(this.formData.address);
            })
            .sort((a, b) => {
              return a.address.localeCompare(b.address);
            })
            .map((owner) => {
              return {
                label: `(${++index}) ${owner.address}`,
                value: { address: owner.address, name: owner.name },
              };
            });
        }
      } else {
        let hasIndex = this.baseOwner.findIndex((owner) => {
          return owner.name === this.formData.name;
        });
        if (hasIndex === -1) {
          allAddressColumn = [];
        } else {
          if (!this.formData.address) {
            allAddressColumn = this.baseOwner
              .filter((owner) => {
                return owner.name === this.formData.name;
              })
              .sort((a, b) => {
                return a.address.localeCompare(b.address);
              })
              .map((owner) => {
                return {
                  label: `(${++index}) ${owner.address}`,
                  value: { address: owner.address, name: owner.name },
                };
              });
          } else {
            allAddressColumn = this.baseOwner
              .filter((owner) => {
                return (
                  owner.address.includes(this.formData.address) &&
                  owner.name === this.formData.name
                );
              })
              .sort((a, b) => {
                return a.address.localeCompare(b.address);
              })
              .map((owner) => {
                return {
                  label: `(${++index}) ${owner.address}`,
                  value: { address: owner.address, name: owner.name },
                };
              });
          }
        }
      }
      this.address.columns = [allAddressColumn];
      uni.hideLoading();
      index = this.address.columns[0].findIndex((item) => {
        return item.value.address.includes(event);
      });
      if (index !== -1) {
        this.$refs.addressPicker.setIndexs([index]);
      }
    },
    closeNamePicker() {
      this.name.show = false;
    },
    closeAddressPicker() {
      this.address.show = false;
    },
    showNamePicker() {
      if (this.baseOwner.length === 0) {
        return;
      }
      if (this.name.show || this.address.show) {
        return;
      }
      uni.showLoading({ title: "请稍候", mask: true });
      let index = 0;
      let allNameColumn = [];
      if (!this.formData.address) {
        if (!this.formData.name) {
          allNameColumn = this.baseOwner
            .sort((a, b) => {
              return a.name.localeCompare(b.name);
            })
            .map((owner) => {
              return {
                label: `(${++index}) ${owner.name}`,
                value: { address: owner.address, name: owner.name },
              };
            });
        } else {
          allNameColumn = this.baseOwner
            .filter((owner) => {
              return owner.name.includes(this.formData.name);
            })
            .sort((a, b) => {
              return a.name.localeCompare(b.name);
            })
            .map((owner) => {
              return {
                label: `(${++index}) ${owner.name}`,
                value: { address: owner.address, name: owner.name },
              };
            });
        }
      } else {
        let hasIndex = this.baseOwner.findIndex((owner) => {
          return owner.address === this.formData.address;
        });
        if (hasIndex === -1) {
          allNameColumn = [];
        } else {
          if (!this.formData.name) {
            allNameColumn = this.baseOwner
              .filter((owner) => {
                return owner.address === this.formData.address;
              })
              .sort((a, b) => {
                return a.name.localeCompare(b.name);
              })
              .map((owner) => {
                return {
                  label: `(${++index}) ${owner.name}`,
                  value: { address: owner.address, name: owner.name },
                };
              });
          } else {
            allNameColumn = this.baseOwner
              .filter((owner) => {
                return (
                  owner.address === this.formData.address &&
                  owner.name.includes(this.formData.name)
                );
              })
              .sort((a, b) => {
                return a.name.localeCompare(b.name);
              })
              .map((owner) => {
                return {
                  label: `(${++index}) ${owner.name}`,
                  value: { address: owner.address, name: owner.name },
                };
              });
          }
        }
      }
      this.name.columns = [allNameColumn];
      uni.hideLoading();
      this.name.show = true;
      this.$nextTick(() => {
        let index = this.name.columns[0].findIndex((item) => {
          return item.value.name.includes(this.formData.name);
        });
        if (index !== -1) {
          this.$refs.namePicker.setIndexs([index]);
        }
      });
    },
    showAddressPicker() {
      if (this.baseOwner.length === 0) {
        return;
      }
      if (this.name.show || this.address.show) {
        return;
      }
      uni.showLoading({ title: "请稍候", mask: true });
      let allAddressColumn = [];
      let index = 0;
      if (!this.formData.name) {
        if (!this.formData.address) {
          allAddressColumn = this.baseOwner
            .sort((a, b) => {
              return a.address.localeCompare(b.address);
            })
            .map((owner) => {
              return {
                label: `(${++index}) ${owner.address}`,
                value: { address: owner.address, name: owner.name },
              };
            });
        } else {
          allAddressColumn = this.baseOwner
            .filter((owner) => {
              return owner.address.includes(this.formData.address);
            })
            .sort((a, b) => {
              return a.address.localeCompare(b.address);
            })
            .map((owner) => {
              return {
                label: `(${++index}) ${owner.address}`,
                value: { address: owner.address, name: owner.name },
              };
            });
        }
      } else {
        let hasIndex = this.baseOwner.filter((owner) => {
          return owner.name === this.formData.name;
        });
        if (hasIndex.length === 0) {
          allAddressColumn = [];
        } else {
          allAddressColumn = this.baseOwner
            .filter((owner) => {
              return owner.name === this.formData.name;
            })
            .sort((a, b) => {
              return a.address.localeCompare(b.address);
            })
            .map((owner) => {
              return {
                label: `(${++index}) ${owner.address}`,
                value: { address: owner.address, name: owner.name },
              };
            });
        }
      }
      this.address.columns = [allAddressColumn];
      uni.hideLoading();
      this.address.show = true;
      this.$nextTick(() => {
        let index = this.address.columns[0].findIndex((item) => {
          return item.value.address.includes(this.formData.address);
        });
        if (index !== -1) {
          this.$refs.addressPicker.setIndexs([index]);
        }
      });
    },
    async search() {
      try {
        await this.$refs.form.validate();
        let formData = JSON.stringify(this.formData);
        uni.navigateTo({
          url: `/sub/owner/home-info/list/index?formData=${formData}`,
        });
      } catch (error) {}
    },
    ownerTypePickerConfirm(event) {
      this.ownerType.value =
        getPickerValue(event)[0].label === "忽略"
          ? ""
          : getPickerValue(event)[0].label;
      this.formData.ownerType = getPickerValue(event)[0].value;
      this.closeOwnerTypePicker();
    },
    closeOwnerTypePicker() {
      this.ownerType.show = false;
    },
    showOwnerTypePicker() {
      this.ownerType.show = true;
    },
    liveStatusPickerConfirm(event) {
      this.liveStatus.value =
        getPickerValue(event)[0].label === "忽略"
          ? ""
          : getPickerValue(event)[0].label;
      this.formData.liveStatus = getPickerValue(event)[0].value;
      this.closeLiveStatusPicker();
    },
    closeLiveStatusPicker() {
      this.liveStatus.show = false;
    },
    showLiveStatusPicker() {
      this.liveStatus.show = true;
    },
    decorationStatusPickerConfirm(event) {
      this.decorationStatus.value =
        getPickerValue(event)[0].label === "忽略"
          ? ""
          : getPickerValue(event)[0].label;
      this.formData.decorationStatus = getPickerValue(event)[0].value;
      this.closeDecorationStatusPicker();
    },
    closeDecorationStatusPicker() {
      this.decorationStatus.show = false;
    },
    showDecorationStatusPicker() {
      this.decorationStatus.show = true;
    },
    homeStatusPickerConfirm(event) {
      this.formData.homeStatus = getPickerValue(event)[0].value;
      this.closeHomeStatusPicker();
    },
    closeHomeStatusPicker() {
      this.homeStatus.show = false;
    },
    showHomeStatusPicker() {
      this.homeStatus.show = true;
    },
    homeTypePickerConfirm(event) {
      this.formData.homeType = getPickerValue(event)[0].value;
      this.closeHomeTypePicker();
    },
    closeHomeTypePicker() {
      this.homeType.show = false;
    },
    showHomeTypePicker() {
      this.homeType.show = true;
    },
    groupPickerConfirm(event) {
      uni.showLoading({ title: "切换组团", mask: true });
      this.formData = {
        uuid: "",
        groupName: getPickerValue(event)[0].value,
        address: "",
        name: "",
        homeType: "",
        homeStatus: "",
        decorationStatus: "",
        liveStatus: "",
        ownerType: "",
        payStyle: "",
        payMonth: [],
      };
      this.decorationStatus.value = "";
      this.liveStatus.value = "";
      this.ownerType.value = "";
      this.address.columns = [[]];
      this.name.columns = [[]];
      this.closeGroupPicker();

      if (this.formData.groupName) {
        this.baseOwner = this.allOwner.filter((owner) => {
          return owner.groupName === this.formData.groupName;
        });
      } else {
        this.baseOwner = this.allOwner;
      }
      uni.hideLoading();
    },
    closeGroupPicker() {
      this.groupName.show = false;
    },
    showGroupPicker() {
      this.groupName.show = true;
    },
  },
};
</script>

<style lang="scss" scoped>
.input::v-deep {
  input {
    z-index: 999999999;
  }
  .u-input__content__clear {
    z-index: 999999999;
  }
}
</style>
